<?php

namespace backend\models;

use Yii;

/**
 * This is the model class for table "tme_outstockinfo".
 *
 * @property integer $ID
 * @property string $OutBillCode
 * @property integer $TAu_ID
 * @property string $OperID
 * @property string $OutTime
 * @property string $Handler
 * @property integer $OutType
 * @property double $TotalMoney
 * @property string $Remark
 *
 * @property TmeOrderinfo[] $tmeOrderinfos
 * @property TmeOutstockdetailsinfo[] $tmeOutstockdetailsinfos
 * @property TauOperinfo $tAu
 */
class TmeOutstockinfo extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'tme_outstockinfo';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['OutBillCode', 'OutTime', 'Handler'], 'required'],
            [['TAu_ID', 'OutType'], 'integer'],
            [['OutTime'], 'safe'],
            [['TotalMoney'], 'number'],
            [['OutBillCode'], 'string', 'max' => 30],
            [['OperID'], 'string', 'max' => 6],
            [['Handler'], 'string', 'max' => 20],
            [['Remark'], 'string', 'max' => 150]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'ID' => 'ID',
            'OutBillCode' => 'Out Bill Code',
            'TAu_ID' => 'Tau  ID',
            'OperID' => 'Oper ID',
            'OutTime' => 'Out Time',
            'Handler' => 'Handler',
            'OutType' => 'Out Type',
            'TotalMoney' => 'Total Money',
            'Remark' => 'Remark',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTmeOrderinfos()
    {
        return $this->hasMany(TmeOrderinfo::className(), ['TMe_ID' => 'ID', 'OutBillCode' => 'OutBillCode']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTmeOutstockdetailsinfos()
    {
        return $this->hasMany(TmeOutstockdetailsinfo::className(), ['ID' => 'ID', 'OutBillCode' => 'OutBillCode']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTAu()
    {
        return $this->hasOne(TauOperinfo::className(), ['ID' => 'TAu_ID', 'OperID' => 'OperID']);
    }
}
